package com.gzhryc.shared_device.oem.h5.agent.event;

import com.gzhryc.common.logging.Logger;
import com.gzhryc.weixin.api.event.IEventService;
import com.gzhryc.weixin.api.event.msg.EventObject;
import com.gzhryc.weixin.api.event.msg.IEventRespMessage;
import com.gzhryc.weixin.api.event.msg.req.LocationEventEntity;
import com.gzhryc.weixin.api.event.msg.req.SubscribeEventEntity;
import com.gzhryc.weixin.api.event.msg.req.TemplateSendJobFinishEvent;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class WxEventService implements IEventService {

	static Pattern eventKeyPat = Pattern.compile("^qrscene_(.*)$");

	static Pattern deviceSnPat = Pattern.compile("^http://weixin.qq.com/q/(.*)$");

	static Logger log = Logger.getLogger(WxEventService.class);

	@Override
	public IEventRespMessage subscribe(SubscribeEventEntity entity, Map<String, Object> data) {
		return null;
	}

	@Override
	public IEventRespMessage unsubscribe(EventObject entity, Map<String, Object> data) {
		return null;
	}

	@Override
	public IEventRespMessage scan(SubscribeEventEntity entity, Map<String, Object> data) {
		return null;
	}

	@Override
	public IEventRespMessage location(LocationEventEntity entity, Map<String, Object> data) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IEventRespMessage templateSendJobFinish(TemplateSendJobFinishEvent event, Map<String, Object> data) {
		// TODO Auto-generated method stub
		return null;
	}

	public static String getStringKey(String eventKey) {
		if (StringUtils.isNotBlank(eventKey)) {
			Matcher mat = eventKeyPat.matcher(eventKey);
			if (mat.find()) {
				String val = mat.group(1);
				return val;
			}
		}
		return null;
	}
}
